<?php

/**
 * This is the model class for table "account".
 *
 * The followings are the available columns in table 'account':
 * @property string $loginName
 * @property string $password_hash
 * @property string $cPhone
 * @property string $cEMail
 * @property string $cRealName
 * @property string $cQuestion
 * @property string $cAnswer
 * @property string $Coin
 * @property string $lockpassword
 * @property string $refName
 */
class Account extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Account the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'account';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('loginName, password_hash, cPhone, cEMail, cRealName, cQuestion, cAnswer, Coin', 'required'),
			array('loginName, cPhone, refName', 'length', 'max'=>32),
			array('password_hash, cEMail, cRealName, cQuestion, cAnswer, Coin, lockpassword', 'length', 'max'=>64),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('loginName, password_hash, cPhone, cEMail, cRealName, cQuestion, cAnswer, Coin, lockpassword, refName', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'loginName' => 'Login Name',
			'password_hash' => 'Password Hash',
			'cPhone' => 'C Phone',
			'cEMail' => 'C Email',
			'cRealName' => 'C Real Name',
			'cQuestion' => 'C Question',
			'cAnswer' => 'C Answer',
			'Coin' => 'Coin',
			'lockpassword' => 'Lockpassword',
			'refName' => 'Ref Name',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('loginName',$this->loginName,true);
		$criteria->compare('password_hash',$this->password_hash,true);
		$criteria->compare('cPhone',$this->cPhone,true);
		$criteria->compare('cEMail',$this->cEMail,true);
		$criteria->compare('cRealName',$this->cRealName,true);
		$criteria->compare('cQuestion',$this->cQuestion,true);
		$criteria->compare('cAnswer',$this->cAnswer,true);
		$criteria->compare('Coin',$this->Coin,true);
		$criteria->compare('lockpassword',$this->lockpassword,true);
		$criteria->compare('refName',$this->refName,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}